package com.olocat.cjx.nsims.service.impl

import com.olocat.cjx.nsims.dao.PatientRepository
import com.olocat.cjx.nsims.pojo.personnel.Patient
import com.olocat.cjx.nsims.service.PatientService
import org.springframework.stereotype.Service
import javax.annotation.Resource

@Service
class PatientServiceImpl : PatientService {
    @Resource
    lateinit var patientRepository: PatientRepository

    override fun getById(id: String): Patient {
        return patientRepository.getOne(id)
    }

    override fun list(): List<Patient> {
        return patientRepository.findAll()
    }

    override fun removeById(id: String) {
        patientRepository.deleteById(id)
    }

    override fun updateById(patient: Patient) {
        patientRepository.save(patient)
    }

    override fun save(patient: Patient) {
        patientRepository.save(patient)
    }

    override fun setAdviceStateById(id: String, adviceState: Int) {
        patientRepository.setAdviceStateById(id, adviceState)
    }

    override fun getPatientsByDepartment(department: Int):List<Patient> {
        return patientRepository.getPatientsByDepartment(department)
    }

    override fun getPatientsByNurse(nurse: String): List<Patient> {
        return patientRepository.getPatientsByNurse(nurse)
    }

    override fun getPatientsByWard(number: String): List<Patient> {
        return patientRepository.getPatientsByWard(number)
    }
}